const { DataTypes } = require('sequelize')
const sequelize = require('../config/database')

const CodeModel = sequelize.define('Code', {
  code_id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    allowNull: false,
    autoIncrement: true
  },
  phone: {
    type: DataTypes.STRING,
    unique: true,
    allowNull: false
  },
  code: {
    type: DataTypes.STRING,
    allowNull: false
  },
  is_used: {
    type: DataTypes.TINYINT,
    allowNull: false,
    defaultValue: 0
  },
  expiresAt: {
    type: DataTypes.TIME,
  }
}, {
  freezeTableName: true,
  tableName: 'code',
  timestamps: false
})

module.exports = CodeModel